package org.dolphin.entity.ar;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.dolphin.base.constant.DatabaseAttribute;
import org.dolphin.entity.inventory.ProductAttribute;
import org.dolphin.entity.measurement.UnitOfMeasurement;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "AR_SALES_INVOICE_DETAIL")
public class SalesInvoiceDetail implements Serializable {
  private static final long serialVersionUID = -9127034619252369235L;
  private String id;
  private SalesInvoiceHeader header;
  private ProductAttribute attribute;
  private BigDecimal qty;
  private UnitOfMeasurement measurement;
  private BigDecimal itemPrice;
  private BigDecimal lineAmount;
  private String remarks;

  @ManyToOne(fetch = FetchType.LAZY, optional = false)
  @JoinColumn(name = "ATTRIBUTE_ID", nullable = false)
  @ForeignKey(name = "FK_AR_SALES_INVOICE_DETAIL_ATTRIBUTE_ID")
  public ProductAttribute getAttribute() {
    return attribute;
  }

  @ManyToOne(fetch = FetchType.LAZY, optional = false)
  @JoinColumn(name = "INVOICE_HEADER_ID", nullable = false)
  @ForeignKey(name = "FK_AR_SALES_INVOICE_DETAIL_HEADER_ID")
  public SalesInvoiceHeader getHeader() {
    return header;
  }

  @Id
  @GeneratedValue(generator = "uuid2")
  @GenericGenerator(name = "uuid2", strategy = "org.dolphin.base.id.generator.CustomUUIDGenerator")
  @Column(name = "ID", nullable = false, length = DatabaseAttribute.ID_LENGTH)
  public String getId() {
    return id;
  }

  @Column(name = "ITEM_PRICE", nullable = false)
  public BigDecimal getItemPrice() {
    return itemPrice;
  }

  @Column(name = "LINE_AMOUNT", nullable = false)
  public BigDecimal getLineAmount() {
    return lineAmount;
  }

  @ManyToOne(fetch = FetchType.LAZY, optional = false)
  @JoinColumn(name = "MEASUREMENT_ID", nullable = false)
  @ForeignKey(name = "FK_AR_SALES_INVOICE_DETAIL_MEASUREMENT_ID")
  public UnitOfMeasurement getMeasurement() {
    return measurement;
  }

  @Column(name = "QTY", nullable = false)
  public BigDecimal getQty() {
    return qty;
  }

  @Column(name = "REMARKS", nullable = true, length = 1000)
  public String getRemarks() {
    return remarks;
  }

  public void setAttribute(ProductAttribute attribute) {
    this.attribute = attribute;
  }

  public void setHeader(SalesInvoiceHeader header) {
    this.header = header;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setItemPrice(BigDecimal itemPrice) {
    this.itemPrice = itemPrice;
  }

  public void setLineAmount(BigDecimal lineAmount) {
    this.lineAmount = lineAmount;
  }

  public void setMeasurement(UnitOfMeasurement measurement) {
    this.measurement = measurement;
  }

  public void setQty(BigDecimal qty) {
    this.qty = qty;
  }

  public void setRemarks(String remarks) {
    this.remarks = remarks;
  }
}
